<template>
  <div class="big">
    <img
      src="
    https://img1.baidu.com/it/u=3042617216,635051447&fm=26&fmt=auto&gp=0.jpg
    "
      alt=""
    />
    <p class="dog" :style="{ background: colostr }" @click="red">
      这是一只很瘦弱的小狗
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      colostr: "",
    };
  },
  methods: {
    red() {
      this.colostr = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(
        Math.random() * 256
      )}, ${Math.floor(Math.random() * 256)})`;
    },
  },
};
</script>

<style>
.big {
  width: 500px;
  height: 400px;
  border: 1px solid #333;
}
.dog {
  width: 500px;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  text-align: center;
}
</style>